$(function(){
	myConsultationList();
	function myConsultationList(){
 		var param = {"userid":USERID,"typeOrder":1,"pageSize":3,"pageNo":1};
		function callBackSlider(data){
			console.log(data);
			if(typeof(data.data)!="undefined"){
				var result = data.data;
				var html = "";
				for(i in result){
					if(result[i].avatar==undefined){                                                                          
						result[i].avatar="../../images/doc-man.png";
					}
					if(result[i].realname==undefined){
						result[i].realname="";
					}
					if(result[i].deptName==undefined){
						result[i].deptName="";
					}
					html +=	'<li v='+result[i].questionid+'><div class="doctor"><img src="'+result[i].avatar+'" />'+result[i].realname+'<span>'+result[i].deptName+'</span>'
								+'<p class="mui-ellipsis-2 font1">'+result[i].questionbody+'</p>';
							if(result[i].qstatus==0){
								html +='<div class="state font1">未领取</div></div>'
							}else if(result[i].qstatus==1){
								html +='<div class="state font1">已领取</div></div>'
							}else if(result[i].qstatus==2){
								html +='<div class="state font1">已解答</div></div>'
							}else if(result[i].qstatus==3){
								html +='<div class="state font1">已关闭</div></div>'
							}
							html +='<div class="time font1"><i class="iconfont icon-033"></i>快速提问<span>'+result[i].createtime+'</span></div></li>';
					
				}

			}
			$(".consultation-list ul").append(html);
			$(".consultation-list") .find("li").on("click",function(){
				var questionId = $(this).attr("v");
				//var  typeOrderId = $(this).attr("num");
				console.log(questionId);
				location.href = "consultation-detail.html?typeOrder=1&questionid="+questionId;
			})
		}
		userCenterModule.queryMyService(param,callBackSlider);
	}
	
	
	var picker = new mui.PopPicker();
	picker.setData([{
	    value: "1",
	    text: "快速提问"
	}, {
	    value: "2",
	    text: "图文咨询"
	}, {
	    value: "3",
	    text: "电话咨询"
	}, {
	    value: "4",
	    text: "极速电话"
	}, {
	    value: "5",
	    text: "在线续方"
	}])
	$("#consultationAll").click(function(){
		picker.show(function(item) {
			$("#consultationAll font").text(item[0].text);
			var number= item[0].value;
			var param = {"userid":USERID,"typeOrder":number,"pageSize":3,"pageNo":1};
			function callBackSlider(data){
				console.log(data);
				var result = data.data;
				if(typeof(result)=="undefined"){
					$(".consultation-list ul").empty();
				} 
				var html = "";
				for(i in result){
					if(result[i].avatar==undefined){
						result[i].avatar="../../images/doc-man.png";
					}
					if(result[i].realname==undefined){
						result[i].realname=" ";
					}
					if(result[i].deptName==undefined){
						result[i].deptName=" ";
					}
					if(result[i].questionid ==undefined){
						result[i].questionid=result[i].id;
					}
					html +=	'<li v='+result[i].questionid+' ><div class="doctor"><img src="'+result[i].avatar+'" />'+result[i].realname+'<span>'+result[i].deptName+'</span>'
							+'<p class="mui-ellipsis-2 font1">'+result[i].questionbody+'</p>';
					if(number==1){
						if(result[i].qstatus==0){
							html +='<div class="state font1">待领取</div></div>'
						}else if(result[i].qstatus==1){
							html +='<div class="state font1">已领取</div></div>'
						}else if(result[i].qstatus==2){
							html +='<div class="state font1">已完成</div></div>'
						}else if(result[i].qstatus==3){
							html +='<div class="state font1">已关闭</div></div>'
						}
						
						html +='<div class="time font1 kusu"><i class="iconfont icon-033"></i>快速提问<span>'+result[i].createtime+'</span></div></li>';
					
					}else if(number==2){
						if(result[i].status==0){
							html +='<div class="state font1">未支付</div></div>'
						}else if(result[i].status==1){
							html +='<div class="state font1">已支付</div></div>'
						}else if(result[i].status==3){
							html +='<div class="state font1">已完成</div></div>'
						}
						html +='<div class="time font1"><i class="iconfont icon-035"></i>图文咨询<span>'+result[i].createtime+'</span></div></li>';
					}else if(number==3){
						if(result[i].status==0){
							html +='<div class="state font1">未支付</div></div>'
						}else if(result[i].status==1){
							html +='<div class="state font1">已支付</div></div>'
						}else if(result[i].status==2){
							html +='<div class="state font1">使用中</div></div>'
						}else if(result[i].status==3){
							html +='<div class="state font1">已使用</div></div>'
						}else if(result[i].status==4){
							html +='<div class="state font1">呼叫失败待退款</div></div>'
						}else if(result[i].status==5){
							html +='<div class="state font1">余额已退</div></div>'
						}else if(result[i].status==6){
							html +='<div class="state font1">执行失败</div></div>'
						}
						html +='<div class="time font1"><i class="iconfont icon-031"></i>电话咨询<span>'+result[i].createtime+'</span></div></li>';
					}else if(number==4){
						if(result[i].status==0){
							html +='<div class="state font1">未支付</div></div>'
						}else if(result[i].status==1){
							html +='<div class="state font1">已支付</div></div>'
						}else if(result[i].status==3){
							html +='<div class="state font1">已完成</div></div>'
						}else if(result[i].status==6){
							html +='<div class="state font1">已退款 </div></div>'
						}
						html +='<div class="time font1"><i class="iconfont icon-032"></i>极速电话<span>'+result[i].createtime+'</span></div></li>';
					}else if(number==5){
						if(result[i].status==1){
							html +='<div class="state font1">待回复</div></div>'
						}else if(result[i].status==2){
							html +='<div class="state font1">已完成</div></div>'
						}else if(result[i].status==3){
							html +='<div class="state font1">关闭</div></div>'
						}
						html +='<div class="time font1"><i class="iconfont icon-034"></i>在线续方<span>'+result[i].createtime+'</span></div></li>';
					}
					console.log(result[i].questionid);
				}
				
				$(".consultation-list ul").empty();
				$(".consultation-list ul").append(html);			
			}
			userCenterModule.queryMyService(param,callBackSlider);
			
			$(".consultation-list") .find("li").on("click",function(){
				var questionId = $(this).attr("v");
				console.log(questionId);
				location.href = "consultation-detail.html?typeOrder="+number+"&id="+questionId;
				
				
				
				
			});
		})
	});
	$(".html-loding").hide();
});
